/**
 * 
 */
package org.hackystat.ui.telemetryviewer.client.common;

import java.util.ArrayList;

import com.google.gwt.user.client.rpc.IsSerializable;

/**
 * This class represents a dataset from a telemetry stream.
 * @author David J. Nickles
 * 
 */
public class DatasetParcel implements IsSerializable {

  private String identifier;
  private double[] domain;
  private double[] range;
  private String label;
  private String axisId;

  /**
   * No parameters constructor.
   */
  public DatasetParcel() {
    super();
    String init = "Default-Dataset";
    this.identifier = init;
    this.domain = new double[0];
    this.range = new double[0];
    this.label = init;
    this.axisId = init;
  }

  /**
   * @return the value of the chart id
   */
  public String getIdentifier() {
    return identifier;
  }

  /**
   * @param identifier set the value of the chart identifier.
   */
  public void setIdentifier(String identifier) {
    this.identifier = identifier;
  }

  /**
   * @return an array of values that represent the domain points.
   */
  public double[] getDomain() {
    return this.domain;
  }

  /**
   * @param domain set array of values that represent the domain points.
   */
  public void setDomain(double[] domain) {
    this.domain = domain;
  }

  /**
   * Assumes an ArrayList of Doubles.
   * @param domain an array of values that represent the domain points.
   */
  public void setTimeDomain(ArrayList domain) {
    double[] result = new double[domain.size()];
    for (int i = 0; i < domain.size(); i++) {
      result[i] = ((Double)domain.get(i)).doubleValue();
    }
    this.domain = result;
  }

  /**
   * @return an array of values that represent the range points.
   */
  public double[] getRange() {
    return this.range;
  }

  /**
   * @param range set an array of values that represent the domain points.
   */
  public void setRange(double[] range) {
    this.range = range;
  }

  /**
   * Assumes an ArrayList of Doubles.
   * @param range an array of values that represent the range points,
   */
  public void setRange(ArrayList range) {
    double[] result = new double[range.size()];
    for (int i = 0; i < range.size(); i++) {
      if (range.get(i) instanceof Double) {
        result[i] = ((Double)range.get(i)).doubleValue();
      }
    }
    this.range = result;
  }

  /**
   * @return the value of the y-axis label.
   */
  public String getLabel() {
    return label;
  }

  /**
   * @param label the value of the y-axis label.
   */
  public void setLabel(String label) {
    this.label = label;
  }

  /**
   * @return the y-axis units.
   */
  public String getAxisId() {
    return axisId;
  }

  /**
   * @param axisId the y-axis units.
   */
  public void setAxisId(String axisId) {
    this.axisId = axisId;
  }
}
